﻿using System;

namespace FDEE.Model
{
    /// <summary>
    /// 花瓶墩主筋
    /// </summary>
    public class MKRebarRecord : RebarBase
    {
        public MKRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
            int aa,int bb,int cc,int dd,int rr) 
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg)
        {
            if (aa < 0 || bb < 0 || cc < 0 || dd < 0 || rr < 0)
            {
                throw new Exception("MIX结果异常请查询原因！");
            }
            A = aa;
            B = bb;
            C = cc;
            D = dd;
            this.r = RebarKnowledge.GerRadius(diameter);
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            R = rr;
            Formula = "L=A+B+C+D";

        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C + D) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MIX长度计算异常，请查找原因！");
            }
        }
    }
    /// <summary>
    /// 加强筋 MKR
    /// </summary>
    public class MKRRebarRecord : RebarBase
    {
        public MKRRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
            int aa, int bb, int cc,  int rr)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg)
        {
            if (aa < 0 || bb < 0 || cc < 0 ||  rr < 0)
            {
                throw new Exception("MIX结果异常请查询原因！");
            }
            A = aa;
            B = bb;
            C = cc;
            this.r = RebarKnowledge.GerRadius(diameter);
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            R = rr;
            Formula = "L=A+B+C";

        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C ) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MIX长度计算异常，请查找原因！");
            }
        }
    }

    /// <summary>
    /// 主筋（MKR1,MKR2）以及加强筋 MKR
    /// </summary>
    public class MKRMRebarRecord : RebarBase
    {
        public MKRMRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
            int aa, int bb, int cc, int rr)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg)
        {
            if (aa < 0 || bb < 0 || cc < 0 || rr < 0)
            {
                throw new Exception("MIX结果异常请查询原因！");
            }
            A = aa;
            B = bb;
            C = cc;
            this.r = RebarKnowledge.GerRadius(diameter);
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            R = rr;
            Formula = "L=A+B+C-r/2-d";

        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C - r * 0.5 - d) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MIX长度计算异常，请查找原因！");
            }
        }
    }
    /// <summary>
    /// 花瓶墩主筋
    /// </summary>
    public class MKLRebarRecord : RebarBase
    {
        public MKLRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
            int aa, int bb, int cc, int dd,int ee,int rr)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg)
        {
            if (aa < 0 || bb < 0 || cc < 0 || dd < 0 || ee < 0 )
            {
                throw new Exception("MIX结果异常请查询原因！");
            }
            A = aa;
            B = bb;
            C = cc;
            D = dd;
            E = ee;
            //F = ff;
            this.r = RebarKnowledge.GerRadius(diameter);
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            R = rr;
            Formula = "L=A+B+C+D+E-r/2-d";

        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C + D+E-r*0.5-d) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MIX长度计算异常，请查找原因！");
            }
        }
    }

    /// <summary>
    /// 主筋A-D  MKAD1,MKAD2
    /// </summary>
    public class MKADRebarRecord : RebarBase
    {
        public MKADRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
            int aa, int bb, int cc,int dd,int rr)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg)
        {
            if (aa < 0 || bb < 0 || cc < 0 || dd < 0 || rr < 0)
            {
                throw new Exception("MIX结果异常请查询原因！");
            }
            A = aa;
            B = bb;
            C = cc;
            D = dd;
            this.r = RebarKnowledge.GerRadius(diameter);
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            R = rr;
            Formula = "L=A+B+C+D-r/2-d";

        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C+D - r * 0.5 - d) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MIX长度计算异常，请查找原因！");
            }
        }
    }


    public class MKABRebarRecord : RebarBase
    {
        public MKABRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
            int aa, int bb, int rr)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg)
        {
            if (aa < 0 || bb < 0 || rr < 0)
            {
                throw new Exception("MIX结果异常请查询原因！");
            }
            A = aa;
            B = bb;
            this.r = RebarKnowledge.GerRadius(diameter);
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            R = rr;
            Formula = "L=A+B";

        }

        public override void SetLength()
        {
            Length = Math.Round((A + B) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MIX长度计算异常，请查找原因！");
            }
        }
    }
}
